package cn.itcast.controller;

import cn.itcast.pojo.Emp;
import cn.itcast.pojo.Result;
import cn.itcast.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Slf4j
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping
    public Result login(@RequestBody Emp emp) {
        return empService.login(emp);
    }

    /*
    测试Session会话技术
     */

    @GetMapping("/s1")
    public void metho1d(HttpSession session) {

       session.setAttribute("name", "付山林");
    }
    @GetMapping("/s2")
    public void method(HttpServletRequest req) {
        HttpSession session = req.getSession();


        Object name = session.getAttribute("name");

        log.info("name:{}", name);
    }
}
